home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #5 & #6 / Amiga Plus CD - 1995 - No. 5 and 6.iso / pd / serien / purity / nr.50 / maccash / src / enabledisablewindow.pas next >
Pascal/Delphi Source File  |  1995-07-12  |  1KB  |  78 lines

  1. unit EnableDisableWindow;
  2.  
  3. INTERFACE
  4.  
  5. Uses
  6.     Intuition, Exec, Reqtools, Utility;
  7.     
  8. Type
  9.     pEnDisWin = ^tEnDisWin;
  10.     tEnDisWin = Record
  11.         edw_req : pRequester;
  12.     End;
  13.     
  14. Procedure EnableWindow(w : pWindow; key : Pointer);
  15. Function DisableWindow(w : pWindow) : Pointer;
  16.  
  17. IMPLEMENTATION
  18.  
  19. Procedure EnableWindow;
  20.  
  21. Var
  22.     edw : pEnDisWin;
  23.  
  24. Begin
  25.     if pLibrary(SysBase)^.lib_Version >= 39 then begin
  26.         SetWindowPointerA(w, NIL);
  27.         edw := pEnDisWin(key);
  28.         If edw <> NIL then begin
  29.             if edw^.edw_Req <> NIL then begin
  30.                 EndRequest(edw^.edw_Req, w);
  31.                 FreeVec(edw^.edw_Req);
  32.                 FreeVec(edw);
  33.             End;
  34.         End;
  35.     End else begin
  36.         if ReqToolsBase <> NIL then begin
  37.             if key <> NIL then begin
  38.                 rtUnLockWindow(w, Key);
  39.             End;
  40.         End;
  41.     End;
  42. End;
  43.  
  44. Function DisableWindow;
  45.  
  46. Var
  47.     t : Array[0..4] of LONG;
  48.     req : pEnDisWin;
  49.  
  50. begin
  51.     DisableWindow := NIL;
  52.     if pLibrary(SysBase)^.lib_Version >= 39 then begin
  53.         t[0] := WA_BusyPointer;
  54.         t[1] := True_;
  55.         t[2] := WA_PointerDelay;
  56.         t[3] := True_;
  57.         t[4] := TAG_END;
  58.         SetWindowPointerA(w, @t);
  59.         req := AllocVec(sizeof(tEnDisWin), MEMF_CLEAR);
  60.         if req <> NIL then begin
  61.             req^.edw_Req := AllocVec(sizeof(tRequester), MEMF_CLEAR);
  62.             if req^.edw_req <> NIL then begin
  63.                 If Request(req^.edw_req, w) then begin
  64.                     DisableWindow := Pointer(req);
  65.                 end else begin
  66.                     FreeVec(req^.edw_Req);
  67.                     FreeVec(req);
  68.                 End;
  69.             End;
  70.         End;
  71.     End else begin
  72.         If ReqtoolsBase <> NIL then
  73.             DisableWindow := Pointer(rtLockWindow(w));
  74.     End;
  75. end;
  76.  
  77. End.
  78.